package cn.achao.csr.api;

import cn.achao.csr.api.factory.SequenceFallbackFactory;
import cn.achao.csr.base.constant.SecurityConstants;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.constraints.NotBlank;

/**
 * @Author: achao
 **/
@FeignClient(contextId = "csrSequenceContextId", path = "/sequence", value = "csr-sequence", fallbackFactory = SequenceFallbackFactory.class)
public interface SequenceApi {

    @RequestMapping(value = "/api/segment/get/{key}")
    Long getSegmentId(@PathVariable("key") @Validated @NotBlank(message = "序列key不能为空") String key,
                      @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
